var isValid = function(s) {
  var arr = []
  for(var i = 0; i < s.length; i++) {
      if (s[i] === '(') {
          arr.push(')')
      }
      if (s[i] === '{') {
          arr.push('}')
      }
      if (s[i] === '[') {
          arr.push(']')
      }
      if (s[i] !== arr.pop()) {
          return false
      }
  }
  return arr.length === 0
};

console.log(isValid('()'))